﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using System.Data.SqlClient;
namespace db_proto
{
    public partial class salon : Form
    {
        public salon()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            textBox2.Text = "";
            textBox1.Text = "";
            textBox3.Text = "";
            textBox4.Text = "";
           
        }

        private void button3_Click(object sender, EventArgs e)
        {

        }

        private void salony_Load(object sender, EventArgs e)
        {
            SqlConnection c = SqlService.getInstance().getConnection();

            SqlCommand cmd = new SqlCommand();
            cmd.Connection = c;
            cmd.CommandText = "select value from colors;";
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = cmd;


            DataSet ds = new DataSet();
            da.Fill(ds);

            grid g = new grid();

            g.setDatasource(ds);
            g.Show();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection c = SqlService.getInstance().getConnection();
            
            SqlCommand add =new SqlCommand();
            
            add.CommandText= "INSERT INTO salony( id,name, country,city ) VALUES(0 , 'G', 'M','gliwice','gliwi')";
    
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = c;
            cmd.CommandText = "select id from Salon;";
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = cmd;

            SqlDataAdapter salonya = new SqlDataAdapter();
            salonya.InsertCommand = add;
            
            //DataSet salony = new DataSet();
           // salonya.Fill(salony);

            grid g = new grid();


            //g.setDatasource(salony);
            //g.Show();
        }  
    }
}
